﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entities;
using DAL;
using Utility;


namespace BUS
{
    public class Tbl_Deal_BUS
    {
        public static Tbl_Deal_Collection Get(string where, int pageindex, int pagesize, string orderby, string orderdirection, out int total)
        {
            Tbl_Deal_DAL dealDAL = new Tbl_Deal_DAL();
            return dealDAL.Get(where, pageindex, pagesize, orderby, orderdirection, out total);
        }
        public static Tbl_Deal_Collection GetAll()
        {
            int total = 0;
            Criteria cri = new Criteria();
            Tbl_Deal_DAL dealDAL = new Tbl_Deal_DAL();
            return dealDAL.Get(cri.Criter, 0, 0, Tbl_Deal_Columns.STT.ToString(), OrderDirection.ASC.ToString(), out total);
        }
        public static Tbl_Deal_Entities GetByID(int iD)
        {
            int total = 0;
            Criteria cri = new Criteria();
            cri.add(Condition.AND, Tbl_Deal_Columns.STT.ToString(), Condition.EQUAL, iD);
            Tbl_Deal_DAL dealDAL = new Tbl_Deal_DAL();
            Tbl_Deal_Collection dealCollection = dealDAL.Get(cri.Criter, 0, 0, Tbl_Deal_Columns.STT.ToString(), OrderDirection.ASC.ToString(), out total);
            if (dealCollection.Count > 0)
                return dealCollection[0];
            return null;
        }

        public static void Insert(Tbl_Deal_Entities deal)
        {
            Tbl_Deal_DAL dealDAL = new Tbl_Deal_DAL();
            dealDAL.insert(deal);
        }
        public static void Update(Tbl_Deal_Entities deal)
        {
            Tbl_Deal_DAL dealDAL = new Tbl_Deal_DAL();
            dealDAL.Update(deal);
        }
        public static void Delete(int id)
        {
            Tbl_Deal_DAL dealDAL = new Tbl_Deal_DAL();
            dealDAL.Delete(id);
        }
    }
}

